home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
uw_1.exe
/
UW_HELP4.HLP
< prev
next >
Wrap
Text File
|
1992-11-03
|
27KB
|
636 lines
`co(4,7);─────────────────────── /// Rectangle Functions ──────────────────────────────`co();
┌──────────────────────────────────────────────────────────────────────────┐
│ `keyword(set_rect,/// set_rect); `keyword(is_rect_equal,/// is_rect_equal); `keyword(rect_overlap,/// rect_overlap); │
│ `keyword(offset_rect,/// offset_rect); `keyword(col_row_inrect,/// col_row_inrect); │
└──────────────────────────────────────────────────────────────────────────┘
The UltraWin library uses the structure RECT to handle information
dealing with rectangular sections of the screen, as in the WINDOW
structure. Included are functions to define the rectangle, check to see
if one rectangle overlaps another, and several other routines that you may
wish to utilize in your program.
`co(10,1);/// set_rect`co(); `keyword(source,[UW_WIN.C]~set_rect);
Takes the variable of type RECT passed by pointer, and sets the upper
left corner and lower right corner to the coordinates passed as integers.
Prototype:
void set_rect(RECT *rectp, int x1, int y1, int x2, int y2);
Parameters:
`co(11,1); RECT *rectp;`co();
A pointer to the rectangle variable.
`co(11,1); int x1, y1, x2, y2`co();
The coordinate pair for the upper left corner (x1,y1) and the lower
right corner (x2,y2) of the rectangle.
Usage:
RECT r;
...
set_rect( &r, 10, 10, 20, 20 );
`co(10,1);/// is_rect_equal`co(); `keyword(source,[UW_WIN.C]~is_rect_equal);
Checks to see if the two rectangles are the same.
Prototype:
int is_rect_equal(RECT *r1, RECT *r2);
Parameters:
`co(11,1); RECT *r1, *r2;`co();
Pointers to the two rectangles to compare.
Usage:
RECT r1, r2;
...
if (is_rect_equal( &r1, &r2 )) {}
`co(10,1);/// rect_overlap`co(); `keyword(source,[UW_WIN.C]~rect_overlap);
Reports on the relationship between two rectangles. This function will
return the status as one of the following (defined in UW.H):
1) FIRST_ENCLOSED
The first rectangle is enclosed within the second.
2) SECOND_ENCLOSED
The second rectangle is enclosed within the first.
3) OVERLAP
The rectangles overlap.
4) NO_OVERLAP
The rectangles do not overlap.
Prototype:
int rect_overlap(RECT *r1, RECT *r2);
Parameters:
`co(11,1); RECT *r1, *r2;`co();
The two rectangles whose relationship to find.
Usage:
RECT r1, r2;
int status;
...
status = rect_overlap( &r1, &r2 );
`co(10,1);/// offset_rect`co(); `keyword(source,[UW_WIN.C]~offset_rect);
Moves the rectangles coordinates by a fixed positive or negative amount
in both the x (column) and y (row) direction.
Prototype:
void offset_rect(RECT *rectp, int col, int row);
Parameters:
`co(11,1); RECT *rectp;`co();
A pointer to the rectangle variable.
`co(11,1); int col, row`co();
The offsets to add to the rectangle's coordinates.
Usage:
RECT r;
...
offset_rect( &r, 5, -4 );
`co(10,1);/// col_row_inrect`co(); `keyword(source,[UW_WIN.C]~cr_inrect);
Checks to see if a particular location is inside (or on the border of)
the rectangle passed.
Prototype:
int col_row_inrect(int col, int row, RECT *rectp);
Parameters:
`co(11,1); int col, row`co();
The coordinate to check.
`co(11,1); RECT *rectp;`co();
A pointer to the rectangle.
Usage:
RECT r;
...
if (col_row_inrect( 5, 5, &r )) {}
`co(4,7);──────────────────────────── /// Data Entry ──────────────────────────────────`co();
┌──────────────────────────────────────────────────────────────────────────┐
│ `keyword(wn_gets,/// wn_gets); `keyword(Masks/Templates,/// Masks/Templates); │
│ `keyword(Validation Chars,/// Validation Chars); `keyword(Strip Mask Option,/// Strip Mask Option); │
│ `keyword(wn_gets_ll,/// wn_gets_ll); │
└──────────────────────────────────────────────────────────────────────────┘
One of the most flexible of all functions in the UltraWin library is
wn_gets. With this one function you can have the user enter dates, times,
prices, strings, and any other type with full control over every character
entered! UltraWin versions 2.00 and up add an even more powerful lower
level function now called by wn_gets to enhance the capabilities even
further. Full compatibility is maintained. The new function called
wn_gets_ll has added the capability to uppercase the first character of
each word, strip the mask completely, only strip the end, or not strip at
all. It can also get input right-to-left, clear an input on the first
non-keypad keypress, and exit when the last character in the input is
entered, saving an extra <Enter> keypress. Furthermore it can allow the
user to input a string longer than the display width of the field and will
scroll within this region automatically! It can also display arrows to
show the user that the string has data to the left or right of the current
display field. If this isn't enough for you, we've added the ability to
call your own validation function for every character entered in
wn_gets_ll. This allows you to validate the user's input "as it happens",
and enhance wn_gets_ll. A new wn_gets_ll hook added in version 2.10 allows
both pre and post processing, as well as the ability to modify the event
itself, giving you the ability to translate keys.
See also `keyword(set_validation_func,/// set_validation_func);.
`co(10,1);/// wn_gets`co(); `keyword(source,[UW_ENTRY.C]~wn_gets);
Gets input from the user according to the restrictions of the mask and
template strings in the window passed by pointer. This function will pass
back the input either with the mask characters included in the string, or
stripped out. A -1 is returned if the mouse is clicked off of the string,
and one of the values KEY_UP, KEY_DN, KEY_PGUP, KEY_PGDN, KEY_ESC,
KEY_ENTER, KEY_TAB or KEY_SHFT_TAB (defined in UW_KEYS.H) is returned if
pressed. Read about the mask and template strings for more information.
Prototype:
int wn_gets( char *str, char *mask, char *template, uchar m_att,
int strip_mode, WINDOW *wnp );
Parameters:
`co(11,1); char *str`co();
The string to be returned by the function.
`co(11,1); char *mask`co();
The mask string.
`co(11,1); char *template`co();
The template string.
`co(11,1); uchar m_att`co();
The attribute (colors) to use when displaying the string.
`co(11,1); int strip_mode`co();
Set to 1 (STRIP_ON) to strip mask characters out of result, or set to 0
(STRIP_OFF) for full mask and result.
`co(11,1); WINDOW *wnp;`co();
A pointer to the window in which entry is to take place.
Usage:
WINDOW *wnp;
int result;
char s[80];
...
result = wn_gets( s, "(___)-___-____", "### ### ####",
wnp->att, STRIP_ON, wnp);
`co(10,1);/// Masks/Templates`co();
The wn_gets function requires you to specify two important strings to
perform its magic. These are the mask and template strings.
The mask string gives you the flexibility of displaying textual
information inside the area to be typed by the user. The mask characters
are displayed in each position of the string that does not have text.
The template string is essentially a string containing validation
characters. Before a character is entered into the string, the wn_gets
function compares the typed character with the template to see if the
character is valid. In addition, the template can be used to force an
uppercase or lowercase character without having the user touch the
CapsLock or Shift keys.
When combined, the mask and template strings give you great flexibility.
The following are just a few examples with explanations of what they
accomplish:
mask = "________" Enter an 8 character string, where all
tplt = "AAAAAAAA" characters must be alphanumeric.
mask = "________" Enter an 8 character string, where
tplt = "****